package com.gyp.exception;


import com.gyp.model.common.IResultCode;
import com.gyp.utils.MessageUtils;
import lombok.Data;

/**
 * @description: 自定义exception
 * @author: xia
 * @createDate: 2020/3/26
 */
@Data
public class BusinessException extends RuntimeException {

    private String code;

    private String message;


    public BusinessException(String format,String... message) {
        String errorMessage = String.format(format,message);
        this.message = errorMessage;
    }

    public BusinessException(IResultCode resultCode) {
        this.message = resultCode.getMsg();
        this.code = resultCode.getCode();
    }

    public BusinessException(String code, String message) {
        this.message = message;
        this.code = code;
    }

    public BusinessException(String key){
        this.code = key;
        this.message = MessageUtils.get(key);
    }

}
